package com.example.domet.controller;

import com.example.domet.bean.Dept;
import com.example.domet.service.DeptService;
import com.example.domet.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dept")
public class DeptController {

    private DeptService deptService;

    @Autowired
    public void setDeptService(DeptService deptService) {
        this.deptService = deptService;
    }

    @PostMapping("listDeptName")
    public Result listDeptName(){
        List<Dept> depts = deptService.selectAll();
        for (Dept a:
        depts) {
            System.out.println(a);
        }
//        List<Dept> deptNameList = deptService();
        return Result.ok().data("deptNameList",depts);
    }
}
